package com.caits.lbs.framework.bean.common;


/**
 * @author dengwei 查询实体的基类 所有查询实体须继承此类
 * 
 */
public class ECondition implements IListCondition
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/** 总记录数 */
	public int totalProperty;
	/** 开始页码 */
	public int page;
	/** 每页多少 */
	public int rows;
	// 总页数
	public int totalPage;
	// 开始行
	public int startRow;
	// 结束行
	public int endRow;

	public String order;

	public String sort;

	//用作简单查询
	public String query;
	public String qtype;
	
	public int getTotalProperty()
	{
		return totalProperty;
	}

	public void setTotalProperty(int totalProperty)
	{
		if (totalProperty > 0)
		{
			if (this.getPage() <= 0)
			{
				this.setStartRow(0);
				this.setEndRow(((this.getRows() > totalProperty) ? totalProperty : this.getRows()));
			}
			else
			{
				this.setStartRow((this.getPage() - 1) * this.getRows());
				this.setEndRow(((this.getStartRow() + this.getRows()) > totalProperty) ? totalProperty : (this.getStartRow() + this.getRows()));

			}
		}

		this.totalProperty = totalProperty;
	}

	public int getRows()
	{
		return rows;
	}

	public void setRows(int rows)
	{
		this.rows = rows;
	}

	public int getStartRow()
	{
		return startRow;
	}

	public void setStartRow(int startRow)
	{
		this.startRow = startRow;
	}

	public int getEndRow()
	{
		return endRow;
	}

	public void setEndRow(int endRow)
	{
		this.endRow = endRow;
	}

	public int getPage()
	{
		return page;
	}

	public void setPage(int page)
	{
		this.page = page;
	}

	public int getTotalPage()
	{
		if (getTotalProperty() % getRows() == 0)
		{
			return getTotalProperty() / getRows();
		}
		else
		{
			return getTotalProperty() / getRows() + 1;
		}
	}

	public void setTotalPage(int totalPage)
	{
		this.totalPage = totalPage;
	}

	public String getOrder()
	{
		return order;
	}

	public void setOrder(String order)
	{
		this.order = order;
	}

	public String getSort()
	{
		return sort;
	}

	public void setSort(String sort)
	{
		this.sort = sort;
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public String getQtype() {
		return qtype;
	}

	public void setQtype(String qtype) {
		this.qtype = qtype;
	}

}
